<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <script>
                function title() {
                    document.getElementById('paciente').className='selected';
                }
                window.onload=title;
            </script>
            <h:form id="customerCreate" enctype="multipart/form-data">
                <h1 class="title">
                    <a href="#" class="back" onclick="history.go(-1)"/>
                    Pesquisar
                </h1>
                <p:messages showDetail="true" autoUpdate="true"  /> 
                <div class="row">
                    <div class="twelve columns"> 
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Filtro</h4></legend>
                            <p:panel id="customerPrimary" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix ">

                                <div class="grid_25">
                                    <p:outputLabel  value="Nome:" styleClass="grid_3"/>
                                    <p:inputText id="name" styleClass="grid_20" value="#{managerSearchCustomer.customer.name}"/>
                                    <p:outputLabel  value="CPF:" styleClass="grid_3"/>
                                    <p:inputMask id="cpf" mask="999.999.999-99" styleClass="grid_8" value="#{managerSearchCustomer.customer.cpf}"/>
                                    <div class="clear"/>

                                    <center>
                                        <div class="buttonAction">
                                            <p:commandButton value="Pesquisar" icon="ui-icon-search"
                                                             update="@form, tablePac" actionListener="#{managerSearchCustomer.searchCustomer()}"
                                                             styleClass="ui-priority-primary" />
                                            <p:button href="indexcustomer.xhtml" value="Cancelar"  icon="ui-icon-arrowreturnthick-1-w" />
                                        </div>
                                    </center>
                                </div>
                            </p:panel>
                        </fieldset>
                        <fieldset>
                            <legend> <h4 style="margin:0 0 10px 0">Resultado</h4></legend>
                            <p:panel id="resultPanel" style="background: none; border: none;" 
                                     styleClass="container_24 clearfix " >

                                <p:dataTable id="tablePac" var="pac" value="#{managerSearchCustomer.searchCustomers}" 
                                             styleClass="grid_24"
                                             rowIndexVar="rowid"
                                             rowKey="#{r.id}"
                                             rows="5" paginator="true"  
                                             paginatorPosition="bottom"
                                             emptyMessage="Nenhum registro"
                                             >  
                                    <f:facet name="header">
                                        Paciente
                                    </f:facet>
                                    <p:column headerText="Ação" width="75">
                                        <p:button icon="ui-icon-pencil" title="Editar dados do Paciente" alt="Editar dados do Paciente"
                                                  href="editcustomer.xhtml?customerEdit=#{pac.id}" 
                                                  style="width: 25px; position: relative;"/>
                                        <p:button icon="ui-icon-search"  title="Visualizar dados do Paciente" alt="Visualizar dados do Paciente"
                                                  href="showcustomer.xhtml?customerShow=#{pac.id}" 
                                                  style="width: 25px; position: relative"/>

                                    </p:column>
                                    <p:column headerText="Nome" width="400">  
                                        <h:outputText value="#{pac.name}"/>
                                    </p:column>  
                                    <p:column headerText="CPF" width="150">  
                                        <h:outputText value="#{pac.cpf}"/>
                                    </p:column>
                                    <p:column headerText="Contato" width="150">  
                                        <h:outputText value="#{pac.cellular}"/>
                                    </p:column>


                                </p:dataTable> 
                            </p:panel>
                        </fieldset>



                    </div>
                </div>

            </h:form>
        </ui:define>
    </ui:composition>

</html>
